/**
 * 
 */
package br.ufmg.ubicomp.droidguide.context;

import java.io.File;
import java.util.Random;

/**
 * @author Heitor Ramos
 *
 */
public class Clima {

	/**
	 * @param args
	 */
	private static File radarFile;
	private double temperature, rain, humidity;
	private Radar radar;
	private Random rand;
	
	/**
	 * 
	 */
	public Clima() {
		super();
/*		This image file will change. Now it is static but it will get the current date and 
*		time correspondent image
*/
		radarFile = new File("src/fig/teste.jpg");
		radar = new Radar(radarFile);
		rand = new Random();
		
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		radarFile = new File("src/fig/teste.jpg");
		Radar radar = new Radar(radarFile);
		Clima c = new Clima();
		double rain;
		rain = c.getRain(1,1);
		System.out.println("Temp "+c.getTemp(1, 1));
		System.out.println("Rain "+rain);
		System.out.println("Humidity "+c.getHumidity(1, 1,rain));
		
		
	}
	
	public double getTemp(double lat, double longi){
		try{
			radar.getRGB(lat, longi);
		}catch (OutOfBoundsException obe){
			obe.printStackTrace();
		} 
		return Math.abs((rand.nextGaussian()*6)+25);
	}
	public double getRain(double lat, double longi){
		return Math.abs((rand.nextGaussian()*30)+20);
	}
	public double getHumidity(double lat, double longi,double rain){
		if (rain < 5){
			return Math.abs(rand.nextGaussian()*.1+.3);
		}else if(rain > 5 && rain < 20){
			return Math.abs(rand.nextGaussian()*.1+.4);
		}else if(rain > 20){
			return Math.abs(rand.nextGaussian()*.1+.7);
		}else{
			return 1;
		}
	}

}
